package com.garlicts.framework.crawler;

import java.util.HashMap;
import java.util.Map;

public class RequestHeadersBuilder {

	private static final String USER_AGENT = "User-Agent";
	private static final String ACCEPT = "Accept";
	private static final String ACCEPT_ENCODING = "Accept-Encoding";
	private static final String ACCEPT_LANGUAGE = "Accept-Language";
	
	private Map<String, String> headerMap = new HashMap<>();
	
	public RequestHeadersBuilder(Builder builder) {
		headerMap.put(USER_AGENT, builder.userAgent);
		headerMap.put(ACCEPT, builder.accept);
		headerMap.put(ACCEPT_ENCODING, builder.acceptEncoding);
		headerMap.put(ACCEPT_LANGUAGE, builder.acceptLanguage);
	}
	
	public static Builder builder() {
		return new Builder();
	}
	
	public static class Builder {
		
		private String userAgent;
		
		private String accept;
		
		private String acceptEncoding;
		
		private String acceptLanguage;
		
		public Builder setUserAgent(String userAgent) {
			this.userAgent = userAgent;
			return this;
		}
		
		public Builder setAccept(String accept) {
			this.accept = accept;
			return this;
		}
		
		public Builder setAcceptEncoding(String acceptEncoding) {
			this.acceptEncoding = acceptEncoding;
			return this;
		}
		
		public Builder setAcceptLanguage(String acceptLanguage) {
			this.acceptLanguage = acceptLanguage;
			return this;
		}
		
		public Map<String, String> build() {
			return new RequestHeadersBuilder(this).headerMap;
		}
		
	}
	
}
